package com.sunlake.spring.main.model.admin.controller;

import com.sunlake.spring.main.common.response.R;
import com.sunlake.spring.main.model.admin.dto.UserEmailDTO;
import com.sunlake.spring.main.model.admin.service.AdminService;
import com.sunlake.spring.main.model.admin.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;
    @GetMapping("/search-user-by-email")
    public R<UserVO> searchUserByEmail(@RequestParam("email") String email) {
        if(email==null||email.equals("")){
            System.out.println("邮箱不能为空");
            return R.error(400,"邮箱不能为空");
        }
        return adminService.searchUserByEmail(new UserEmailDTO(email));

    }
}
